import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
class Test04 extends StatefulWidget {
  @override
  _Test04State createState() => _Test04State();
}

class _Test04State extends State<Test04> {
  var textInput;
  @override
  Widget build(BuildContext context) {
    return Container(
      child: TextField(
        onChanged: (text){
          setState(() {
            textInput=text;
          });
        },
        decoration: InputDecoration(
            prefix: Icon(Icons.access_alarm),
            suffix: Icon(Icons.style),
            icon: Icon(Icons.person),
            labelText: "ssssss",
            labelStyle: TextStyle(color: Colors.red),
            helperText: "请输入姓名",
            helperStyle: TextStyle(color: Colors.yellow),
            helperMaxLines: 1,
            hintText: "输入姓名",
            hintStyle: TextStyle(color: Colors.grey.withOpacity(.4)),
            hintMaxLines: 1,
            errorText: '姓名为中文',
            errorStyle: TextStyle(color: Colors.yellow),
            errorBorder: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.red)
            ),
            counterText: "${textInput.toString().length}/32"
        ),
      ),
    );
  }
}

